package com.study.controller;

import com.study.entity.Userinfos;
import com.study.service.HbaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
public class HbaseController {
    @Autowired
    private HbaseService hbaseService;

    @RequestMapping("/add")
    public String add(@RequestBody Userinfos user){
        hbaseService.insert(user);
        return "ok";
    }

    @RequestMapping("/single/{rowkey}")
    public Userinfos select(@PathVariable("rowkey") String rowkey){
        return hbaseService.findByRowkey(rowkey);
    }

    @RequestMapping("/getAll")
    public List<Userinfos> getAll(){
        return hbaseService.findAll();
    }

    @RequestMapping("/findByName/{name}")
    public List<Userinfos> findByName(@PathVariable("name") String name){
        return hbaseService.findUserByPrefixName(name);
    }
}
